package com.example.blog.model;

import com.example.blog.enums.ResultStatus;
import lombok.Data;
import org.apache.logging.log4j.message.ReusableMessage;

import java.security.PublicKey;

@Data
public class Result<T> {
    //业务码 200-成功 -1-失败 -2 -未登录
    private ResultStatus code;
    //错误信息
    private String errMsg;
     //接口响应的数据
    private T data;
    public  static <T> Result success(T data){
        Result result = new Result();
        result.setCode(ResultStatus.SUCCESS);
        result.setData(data);
        result.setErrMsg("");
        return result;
    }
    public  static <T> Result fail(String errMsg){
        Result result = new Result();
        result.setCode(ResultStatus.FAIL);
        result.setData(null );
        result.setErrMsg(errMsg);
        return result;
    }

}
